const path = require('path')
const resolve = dir => {
    return path.join(__dirname, dir)
}
module.exports = {
    publicPath: './',
    chainWebpack: config => {
        config.resolve.alias
            .set('_c', resolve('src/components')) // key,value自行定义，比如.set('@@', resolve('src/components'))
    },
    devServer: {
        port: 8080,
        host: 'localhost',
        open: true,
        https: false,
        proxy: {
            //备品备件
            "/sparePart": {
                target: "http://api-parts-system-cluster01.hithium.com/",
                changeOrigin: true,
                pathRewrite: {
                    //下面的key是一个正则表达式它的/api前加上^和不加^符号差别非常大
                    "^/sparePart": "",
                },
            },
            "/m2i": {
                target: "http://api-m2i-system-cluster01.hithium.com/",
                changeOrigin: true,
                pathRewrite: {
                    //下面的key是一个正则表达式它的/api前加上^和不加^符号差别非常大
                    "^/m2i": "",
                },
            },
            "/ticket": {
                target: "http://api-ticket-system-cluster01.hithium.com/",
                changeOrigin: true,
                pathRewrite: {
                    //下面的key是一个正则表达式它的/api前加上^和不加^符号差别非常大
                    "^/ticket": "",
                },

            },
            "/apm": {
                target: "http://portal-apm-system-cluster01.hithium.com/",
                changeOrigin: true,
                pathRewrite: {
                    //下面的key是一个正则表达式它的/api前加上^和不加^符号差别非常大
                    "^/apm": "",
                },
                onProxyReq(proxyReq) {
                    console.log('proxyReq=>', proxyReq)
                    proxyReq.removeHeader('origin')
                }
            },
            "/api": {
                target: "http://api-apm-system-cluster01.hithium.com/",
                changeOrigin: true,
                pathRewrite: {
                    //下面的key是一个正则表达式它的/api前加上^和不加^符号差别非常大
                    "^/api": "",
                },
                onProxyReq(proxyReq) {
                    proxyReq.removeHeader('origin')
                }
            },
            "/bee": {
                target: "http://api-bee-system-cluster01.hithium.com/",
                changeOrigin: true,
                pathRewrite: {
                    "^/bee": "",
                },
                onProxyReq(proxyReq) {
                    proxyReq.removeHeader('origin')
                }
            },
            "/junrong": {
                target: "http://urw90adq.dongtaiyuming.net/",
                changeOrigin: true,
                pathRewrite: {
                    "^/junrong": "",
                },
                onProxyReq(proxyReq) {
                    proxyReq.removeHeader('origin')
                }
            }

        }
    }
    // devServer: {
    //     port: 8081,
    //     host: 'localhost',
    //     open: true,
    //     https: false,
    //     client: {
    //         overlay: false
    //     },
    //     proxy: {
    //         //备品备件
    //         "/sparePart": {
    //             target: "https://api-parts-system-cluster01.hithium.com/",
    //             changeOrigin: true,
    //             pathRewrite: {
    //                 //下面的key是一个正则表达式它的/api前加上^和不加^符号差别非常大
    //                 "^/sparePart": "",
    //             },
    //         },
    //         "/m2i": {
    //             target: "https://api-m2i-system-cluster01.hithium.com",
    //             changeOrigin: true,
    //             pathRewrite: {
    //                 //下面的key是一个正则表达式它的/api前加上^和不加^符号差别非常大
    //                 "^/m2i": "",
    //             },
    //
    //         },
    //         "/ticket": {
    //             target: "https://api-ticket-system-cluster01.hithium.com/",
    //             changeOrigin: true,
    //             pathRewrite: {
    //                 //下面的key是一个正则表达式它的/api前加上^和不加^符号差别非常大
    //                 "^/ticket": "",
    //             },
    //
    //         },
    //         "/apm": {
    //             target: "https://portal-apm-system-cluster01.hithium.com/",
    //             changeOrigin: true,
    //             pathRewrite: {
    //                 //下面的key是一个正则表达式它的/api前加上^和不加^符号差别非常大
    //                 "^/apm": "",
    //             },
    //             onProxyReq(proxyReq) {
    //                 proxyReq.removeHeader('origin')
    //             }
    //         },
    //     },
    // },
}
